package dfs_bfs.test784;

import java.util.ArrayList;
import java.util.List;

/**
 * 字母大小写全排列
 * @author code_yc
 * @version 1.0
 * @date 2020/7/8 13:51
 */
public class Solution1 {

    // DFS求解
    List<String> ans = new ArrayList<>();

    public List<String> letterCasePermutation(String S) {
        dfs(S.toCharArray(), 0);
        return ans;
    }

    private void dfs(char[] chars, int c) {
        if (c == chars.length) {
            ans.add(String.valueOf(chars));
            return;
        }
        dfs(chars, c + 1);
        if (chars[c] >= 'A') {
            chars[c] ^= 32;
            dfs(chars, c + 1);
        }
    }
}
